<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta content="App Inventor for Android" name="description">
    <meta content="Android, Blocks App Inventor, Mobile, Phone, IDE" name="keywords">
    <title>
      Control Blocks - App Inventor for Android
    </title>
    <link href="../../../static/images/appinventor-16.png" rel="SHORTCUT ICON" type="image/ico">
    <link href="../../../static/images/appinventor-16.png" rel="icon" type="image/png">
    <link href="../../../static/css/appinventor.css" rel="stylesheet" type="text/css">
<!-- ADD Google Analytics here -->
<!-- END Google Analytics here -->
    <style type="text/css">
img.c2 {border-width:0}
    div.c1 {clear:both;}
    </style>
  </head>
  <body>
    <div id="aiac">
      <div class="main-container">
        <div class="header">
          <div class="header-title">
            <a href="../../../about/index.html"><img alt="" src="../../../static/images/appinventor_logo.gif"></a>
          </div>
            <div class="header-search">
<!-- ADD Google Custom Search -->
<!-- END Google Custom Search -->
              <div class="header-search-query">
              </div>
              <div class="header-search-button">
              </div>
            </div>
          <div class="header-login">
            <div class="header-login-greeting">
              Learn about App Inventor
            </div>
          </div>
        </div>
        <div class="customhr customhr-green"></div>
<!-- ADD Google Search Results -->
<!-- END Google Search Results -->
        <div id="navigation">
          <div id="navigation-links">
            <div class="navigation-link-option" id="navigation-link-home">
              <a href="../../../about/index.html">About</a>
            </div>
            <div class="navigation-link-option navigation-link-active" id="navigation-link-learn">
              <a href="../../../learn/index.html">Learn</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-forum">
              <a href="../../../forum/index.html">Forum</a>
            </div>
            <div class="navigation-link-option" id="navigation-link-myappinventor">
              <a href="">My Projects</a><div>(coming soon)</div>
            </div>
          </div>
          <div id="navigation-breadcrumb">
            <a href="../../../learn/index.html">Learn</a> &gt; <a href="../../../learn/reference/index.html">Reference</a> &gt; Control Blocks &gt;
          </div>
          <div class="c1"></div>
        </div>
        <div class="customhr customhr-gray"></div>
        <div class="content">
          <div class="content-body">
            <div class="learn-page">
              <h1>
                Control Blocks
              </h1>
              <ul>
                <li>
                  <a href="#if">if</a>
                </li>
                <li>
                  <a href="#ifelse">ifelse</a>
                </li>
                <li>
                  <a href="#choose">choose</a>
                </li>
                <li>
                  <a href="#foreach">foreach</a>
                </li>
                <li>
                  <a href="#forrange">for range</a>
                </li>
                <li>
                  <a href="#while">while</a>
                </li>
                <li>
                  <a href="#getstarttext">get start text</a>
                </li>
                <li>
                  <a href="#closescreen">close screen</a>
                </li>
                <li>
                  <a href="#closescreenwithresult">close screen with result</a>
                </li>
              </ul>
              <h2 id="if">
                if
              </h2><img alt="" src="images/if.png">
              <p>
                Tests a given condition. If the condition is true, performs the actions in a given sequence of blocks; otherwise, the blocks are ignored.
              </p>
              <h2 id="ifelse">
                ifelse
              </h2><img alt="" src="images/ifelse.png">
              <p>
                Tests a given condition. If the result is true, performs the actions in the <code>then-do</code> sequence of blocks; otherwise, performs the actions in the <code>else-do</code> sequence of blocks.
              </p>
              <h2 id="choose">
                choose
              </h2><img alt="" src="images/choose.png">
              <p>
                Tests a given condition. If the condition is true, performs the actions in the <code>then-do</code> sequence of blocks and returns the <code>then-return</code> value; otherwise, performs the actions in the <code>else-do</code> sequence of blocks and returns the <code>else-return</code> value.
              </p>
              <h2 id="foreach">
                foreach
              </h2><img alt="" src="images/foreach.png">
              <p>
                Runs the blocks in the <code>do</code> section for each item in the list <code>in list</code>. Use the given variable name to refer to the current list item.
              </p>
              <h2 id="forrange">
                for range
              </h2>
              <p>
                Runs the block in the <code>do</code> section for each numeric value in the range from start to end, stepping the value each time. Use the given variable name to refer to the current value.
              </p>
              <h2 id="while">
                while
              </h2><img alt="" src="images/while.png">
              <p>
                Tests the <code>test</code> condition. If true, performs the action given in <code>do</code>, then tests again. When <code>test</code> is false, the block ends.
              </p>
              <h2 id="getstarttext">
                get start text
              </h2><img alt="" src="images/getstarttext.png">
              <p>
                Returns the text passed to this app when the app was started, if any.
              </p>
              <h2 id="closescreen">
                close screen
              </h2><img alt="" src="images/closescreen.png">
              <p>
                Closes the app.
              </p>
              <h2 id="closescreenwithresult">
                close screen with result
              </h2><img alt="" src="images/closescreenwithresult.png">
              <p>
                Closes the app and sets the variable APP_INVENTOR_RESULT to the given value.
              </p>
            </div>
          </div>
        </div>
        <div class="footer">
          <div class="footer-legal">
            <p>
              <a href="http://creativecommons.org/licenses/by/3.0/" rel="license"><img alt="Creative Commons License" class="c2" src="http://i.creativecommons.org/l/by/3.0/88x31.png"></a><br>
              This work is licensed under a <a href="http://creativecommons.org/licenses/by/3.0/" rel="license">Creative Commons Attribution 3.0 Unported License</a> .
            </p>
            <p>
              The original work by Google has been modified<br>
              <!-- The modified work was translated from English to [language]<br> -->
              <a href="../../../about/index.html">About</a> | <a href="../../../about/privacy.html">Privacy</a> | <a href="../../../about/termsofservice.html">Terms</a>
            </p>
          </div>
          <div class="footer-lastupdate">
            <script type="text/javascript">
if (document.lastModified != '') {
                var m = "Page last updated: " + document.lastModified;
                var p = m.length-8;
                document.writeln("<center>");
                document.write(m.substring(p, 0));
                document.writeln("<\/center>");
              }
            </script>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
